package com.py.credit.entity.enums;

import com.py.credit.entity.common.OptionalColumn;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * 规则显示列枚举
 *
 * @author jicm
 */
public enum ResourceShareLogFieldsEnum {

    SHARELOG_ID("id", "共享日志id", "varchar", "", true, false, new HashMap<>(), false, false),
    realname("realname", "姓名", "varchar", "input", true, true, new HashMap<>(), true, true),
    username("username", "登录名", "varchar", "input", true, true, new HashMap<>(), true, true),
    deptname("deptname", "所属部门", "varchar", "input", true, true, new HashMap<>(), true, true),
    
    ip("ip", "ip地址", "varchar", "input", true, true, new HashMap<>(), true, false),
    SEARCH_CATALOG("search_catalog", "查询目录", "varchar", "input", true, true, new HashMap<>(), true, false),
    SORT_TYPE_STR("sort_type", "分类类型", "varchar", "select", true, true, new HashMap<String, String>() {
        private static final long serialVersionUID = 3839433627037454999L;
        {
            put("1", "一站式");
            put("2", "信用核查");
            put("3", "外部接口");
        }

    }, true, false),
    CONTENT("content", "查询内容", "varchar", "", true, false, new HashMap<>(), false, false),
    OPER_TIME_STR("oper_time", "查询时间", "timestamp", "", true, false, new HashMap<>(), false, false);

    private String colNameEN;
    private String colNameCN;
    private String type;
    private boolean defaultShow;
    private boolean searchIsShow;
    private String widget;
    private boolean fuzzy;
    private HashMap<String, String> widgetValue;
    private boolean advanceConditionShow;

    private ResourceShareLogFieldsEnum(String colNameEN, String colNameCN, String type, String widget, boolean defaultShow,
                                       boolean fuzzy, HashMap<String, String> widgetValue, boolean advanceConditionShow, boolean searchIsShow) {
        this.colNameEN = colNameEN;
        this.colNameCN = colNameCN;
        this.type = type;
        this.widget = widget;
        this.defaultShow = defaultShow;
        this.fuzzy = fuzzy;
        this.widgetValue = widgetValue;
        this.advanceConditionShow = advanceConditionShow;
        this.searchIsShow = searchIsShow;
    }

    public String getColNameEN() {
        return colNameEN;
    }

    public void setColNameEN(String colNameEN) {
        this.colNameEN = colNameEN;
    }

    public String getColNameCN() {
        return colNameCN;
    }

    public void setColNameCN(String colNameCN) {
        this.colNameCN = colNameCN;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public boolean isDefaultShow() {
        return defaultShow;
    }

    public void setDefaultShow(boolean defaultShow) {
        this.defaultShow = defaultShow;
    }

    public HashMap<String, String> getWidgetValue() {
        return widgetValue;
    }

    public void setWidgetValue(HashMap<String, String> widgetValue) {
        this.widgetValue = widgetValue;
    }

    public String getWidget() {
        return widget;
    }

    public void setWidget(String widget) {
        this.widget = widget;
    }

    public boolean isFuzzy() {
        return fuzzy;
    }

    public void setFuzzy(boolean fuzzy) {
        this.fuzzy = fuzzy;
    }

    public boolean isAdvanceConditionShow() {
        return advanceConditionShow;
    }

    public void setAdvanceConditionShow(boolean advanceConditionShow) {
        this.advanceConditionShow = advanceConditionShow;
    }

    public boolean isSearchIsShow() {
        return searchIsShow;
    }

    public void setSearchIsShow(boolean searchIsShow) {
        this.searchIsShow = searchIsShow;
    }

    public static List<OptionalColumn> getOptionalColumns() {
        List<OptionalColumn> OptionalColumns = new ArrayList<OptionalColumn>();
        ResourceShareLogFieldsEnum[] values = ResourceShareLogFieldsEnum.values();

        for (ResourceShareLogFieldsEnum value : values) {

            OptionalColumn optionalColumn = new OptionalColumn(value.getColNameEN(), value.getColNameCN(),
                    value.getType(), value.isDefaultShow(), value.getWidget(), value.isFuzzy(), value.getWidgetValue(),
                    value.isSearchIsShow());
            OptionalColumns.add(optionalColumn);
        }

        return OptionalColumns;

    }

    public static List<OptionalColumn> getAdvancedConditionColumns() {

        List<OptionalColumn> OptionalColumns = new ArrayList<OptionalColumn>();

        ResourceShareLogFieldsEnum[] values = ResourceShareLogFieldsEnum.values();

        for (ResourceShareLogFieldsEnum value : values) {

            if (value.isAdvanceConditionShow()) {

                OptionalColumn optionalColumn = new OptionalColumn(value.getColNameEN(), value.getColNameCN(),
                        value.getType(), value.isDefaultShow(), value.getWidget(), value.isFuzzy(),
                        value.getWidgetValue(), value.isSearchIsShow());
                OptionalColumns.add(optionalColumn);
            }

        }
        return OptionalColumns;

    }

    public static List<String> getDefaultShowColumnEN() {

        List<String> columns = new ArrayList<String>();

        ResourceShareLogFieldsEnum[] values = ResourceShareLogFieldsEnum.values();

        for (ResourceShareLogFieldsEnum value : values) {

            if (value.isDefaultShow()) {

                columns.add(value.getColNameEN());
            }

        }
        return columns;

    }

}
